﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using IDAL;
using DBUtility;

namespace SqlDbDAL
{
    public class IDoctorImpl : IDoctor
    {
        /// <summary>
        /// 返回某医生的信息
        /// </summary>
        /// <param name="doctorID">医生注册网号</param>
        /// <returns></returns>
        public DataTable getDoctorInfoByID(int doctorID)
        {
            string strSQL = "select * from TB_DOCTOR_INFO where SREGISTERID=" + doctorID.ToString();
            DataTable doctorInfoDT = new DataTable();
            SqlDataBase sqldatabase = new SqlDataBase();
            doctorInfoDT = sqldatabase.GetDataTable(strSQL);
            if (doctorInfoDT != null)
                return doctorInfoDT;
            else
                return null;
        }

        /// <summary>
        /// 获取某一医院的所有医生信息
        /// </summary>
        /// <param name="hosipitalname">医院名称</param>
        /// <returns></returns>
        public DataTable getDoctorListByHosipital(string hosipitalname)
        {
            string strSQL = "select * from TB_DOCTOR_INFO where SHOSIPITAL='" + hosipitalname + "'";
            DataTable doctorInfo = new DataTable();
            SqlDataBase sqldatabase = new SqlDataBase();
            doctorInfo = sqldatabase.GetDataTable(strSQL);
            if (doctorInfo != null)
                return doctorInfo;
            else
                return null;
        }

        /// <summary>
        /// 获得某一专长的医生列表
        /// </summary>
        /// <param name="epertise"></param>
        /// <returns></returns>
        public DataTable getDoctorListByEpertise(string epertise)
        {
            string strSQl = "select * from TB_DOCTOR_INFO where SEPERTISE='" + epertise + "'";
            DataTable doctorInfo = new DataTable();
            SqlDataBase sqldatabase = new SqlDataBase();
            doctorInfo = sqldatabase.GetDataTable(strSQl);
            if (doctorInfo != null)
                return doctorInfo;
            else
                return null;
        }



        /// <summary>
        /// 保存医生回复，成功返回1，失败返回0
        /// </summary>
        /// <param name="doctorID">医生ID</param>
        /// <param name="strdate">日期</param>
        /// <param name="comment">内容</param>
        /// <param name="answer">是否回复</param>
        /// <returns></returns>
        public int saveAnswer(int doctorID, string strdate, string comment, int answer)
        {
            string strSQL = "update TB_MEDICAL_RECORDS set NDOCTORID=" + doctorID.ToString() + ",DATIME=" + strdate + ",NANSWER=" + answer.ToString();
            SqlDataBase sqldatabase = new SqlDataBase();
            bool k = sqldatabase.ExeSQL(strSQL);
            if (k)
                return 1;
            else
                return 0;
        }
    }
}
